<template>
    <div>
      <a-card class="card" :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="vertical">
        <a-row :gutter="48">
          <a-col :sm="{span:12}" :lg="{span:8}" :xl="{span:6}" >
            <a-form-item label="院系">
              <a-select :allowClear="true" v-model="queryParam.ssyxm" >
                <a-select-option v-for="i in selectMenu.yx" :key="i.id" :value="i.dwh">{{ i.dwmc }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:8}" :xl="{span:6}" >
            <a-form-item label="研究方向">
              <a-select :allowClear="true" v-model="queryParam.ssyxm">
                <a-select-option v-for="i in selectMenu.yx" :key="i.id" :value="i.dwh">{{ i.dwmc }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:8}" :xl="{span:6}">
            <a-form-item label="专业">
              <a-select :allowClear="true" v-model="queryParam.zy">
                <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" style="text-align:center">
            <a-button type="primary" @click="loadData">查询</a-button>
            <a-button type="primary" @click="handleAddMentor">添加招生导师</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    </a-card>
        <a-table
            ref="table"
            size="default"
            rowKey="key"
            :columns="dscolumns"
            :loading="loading"
            :dataSource="dsdata"
            :pagination="false"
        >
        <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 }}
        </span>
        </a-table>
        <a-table
            ref="table"
            size="default"
            rowKey="key"
            :columns="columns"
            :loading="loading"
            :dataSource="data"
            :pagination="false"
            :scroll="{ x: 1500 }"
        >
        <template slot="action" slot-scope="text,record">
          <a @click="handleDelete(record.key)">删除</a>
        </template>
        <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 }}
        </span>
        </a-table>
        </div>
</template>

<script>
import moment from 'moment'
import { STable } from '~'
import { mapState } from 'vuex'

const selectArr = ['TYPE0126', 'TYPE0075', 'TYPE0125', 'TYPE0072']

export default {
  components: {
    STable
  },
  props: {
    confirmHandleVisiable: {
      default: false
    },
    info: {
      default: () => []
    },
    // 是否禁止编辑
    disabledStop: {
      default: true
    }
  },
  data () {
    return {
      moment,
      queryParam: {},
      loading: false,
      dsdata: [],
      data: [],
      dscolumns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '导师编号',
          dataIndex: 'dsbh'
        },
        {
          title: '姓名',
          dataIndex: 'xm'
        },
        {
          title: '指导院系',
          dataIndex: 'zdyx'
        },
        {
          title: '指导专业',
          dataIndex: 'zdzy'
        },
        {
          title: '指导研究方向',
          dataIndex: 'zdyjfx'
        }
      ],
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '导师编号',
          dataIndex: 'kssj'
        },
        {
          title: '姓名',
          dataIndex: 'xm'
        },
        {
          title: '指导研究方向',
          dataIndex: 'zdyjfx'
        },
        {
          title: '操作',
          dataIndex: 'cz',
          fixed: 'right',
          width: 120,
          scopedSlots: { customRender: 'action' }
        }
      ],
      selectMenu: {
        yx: [] // 院系
      }
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0321: state => state.app['TYPE0321'], // 是否在岗
      TYPE0126: state => state.app['TYPE0126'], // 年级
      TYPE0011: state => state.app['TYPE0011'] // 性别
    })
  },
  created () {
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
    this.loadData()
    this.loadDsData()
    this.data = this.info['data']
    this.dsdata = this.info['dsdata']
  },
  methods: {
    // 关闭
    onClose () {
      this.$emit('close')
    },
    // 加载数据
    loadData () {
      return new Promise(resolve => { resolve() }).then(res => {
        this.data = [{
          kssj: 'A001',
          xm: '小李子',
          dw: 'AI',
          key: 1
        }, {
          kssj: 'A001',
          xm: '小李子',
          dw: 'AI',
          key: 12
        }, {
          kssj: 'A001',
          xm: '小李子',
          dw: 'AI',
          key: 13
        }]
      })
    },
    // 加载数据
    loadDsData () {
      return new Promise(resolve => { resolve() }).then(res => {
        this.dsdata = [{
          dsbh: 'A001',
          xm: '小李子',
          dzdyxw: 'AI',
          zdzy: 'php',
          zdyjfx: '删库',
          key: 1
        }, {
          dsbh: 'A001',
          xm: '小李子',
          dzdyxw: 'AI',
          zdzy: 'php',
          zdyjfx: '删库',
          key: 11
        }, {
          dsbh: 'A001',
          xm: '小李子',
          dzdyxw: 'AI',
          zdzy: 'php',
          zdyjfx: '删库',
          key: 12
        }]
      })
    },
    // 输出数据
    GetInfo () {
      return this.data
    },
    // 删除
    handleDelete (key) {
      const dataSource = [...this.data]
      this.data = dataSource.filter(item => item.key !== key)
    },
    handleAddMentor () {

    }
  }
}
</script>

<style lang="less">
.fullscreen{
    .ant-drawer-wrapper-body{
        height: 100%;
        overflow: auto;
    }
}
</style>
